// modify-openid.js

var ModifyOpenIDServer = {};

ModifyOpenIDServer.load = function() {
	var id = window.arguments[0].id
	var server = AppalachianDB.getServerInfo(id);
	document.getElementById("openid-server-textbox").value = server.url;
	document.getElementById("openid-server-textbox").focus();
};

ModifyOpenIDServer.unload = function() {
	// do nothing
};

ModifyOpenIDServer.cancel = function() {
	window.close();
};

ModifyOpenIDServer.save = function() {
	var messages = document.getElementById("message-bundle");
	try {
		var server = document.getElementById("openid-server-textbox").value;

		if (server == "") {
			alert(messages.getString("blankserver"));
		} else {
			document.getElementById("ok-button").disabled = true;
			AppalachianDB.modifyServer(window.arguments[0].id, window.arguments[0].openid, server);
			window.close();
		}
	} catch (e) {
		alert(messages.getString("failure") + " " + e);
	}
};
